<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="130px">
      <el-form-item label="物料名称" prop="itemName">
        <el-input
          v-model="queryParams.itemName"
          placeholder="请输入物料名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料名称（英文）" prop="itemNameEn">
        <el-input
          v-model="queryParams.itemNameEn"
          placeholder="请输入物料名称（英文）"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料编号"  prop="itemCode">
        <el-input
          v-model="queryParams.itemCode"
          placeholder="请输入物料编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料子编号"  prop="itemId">
        <el-input
          v-model="queryParams.itemId"
          placeholder="请输入物料子编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="规格型号" prop="spec">
        <el-input
          v-model="queryParams.spec"
          placeholder="请输入规格型号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="批次号" prop="lot">
        <el-input
          v-model="queryParams.lot"
          placeholder="请输入批次号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应商" prop="supplyId">
        <el-input
          v-model="queryParams.supplyId"
          placeholder="请输入供应商"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应商名称" prop="supplyName">
        <el-input
          v-model="queryParams.supplyName"
          placeholder="请输入供应商名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料分类" prop="classId">
        <el-select style="width: 100%" v-model="queryParams.classId" placeholder="物料分类" >
          <el-option
            v-for="dict in classOptions"
            :key="dict.classId"
            :label="dict.className"
            :value="dict.classId"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="仓库编码" prop="stockId">
        <el-input
          v-model="queryParams.stockId"
          placeholder="请输入仓库编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="仓库名称" prop="stockName">
        <el-input
          v-model="queryParams.stockName"
          placeholder="请输入仓库名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="库区编码" prop="kuquCode">
        <el-input
          v-model="queryParams.kuquCode"
          placeholder="请输入库区编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="库区名称" prop="kuquName">
        <el-input
          v-model="queryParams.kuquName"
          placeholder="请输入库区名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="库位编码" prop="kuweiCode">
        <el-input
          v-model="queryParams.kuweiCode"
          placeholder="请输入库位编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="排产编号" prop="pcId">
        <el-input
          v-model="queryParams.pcId"
          placeholder="请输入排产编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="销售订单号" prop="saleOrderCode">
        <el-input
          v-model="queryParams.saleOrderCode"
          placeholder="请输入销售订单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出库单号" prop="chukuId">
        <el-input
          v-model="queryParams.chukuId"
          placeholder="请输入出库单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入库单号" prop="rukuId">
        <el-input
          v-model="queryParams.rukuId"
          placeholder="请输入入库单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入库时间" prop="rukuDate">
        <el-date-picker clearable
          v-model="queryParams.rukuDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择入库时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['business:ccStockInfo:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['business:ccStockInfo:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['business:ccStockInfo:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['business:ccStockInfo:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="ccStockInfoList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="公司代码" align="center" prop="factoryCode" />
      <el-table-column label="公司名称" align="center" prop="factoryName" />
      <el-table-column label="物料名称" width="150" show-overflow-tooltip align="center" prop="itemName" />
      <el-table-column label="物料名称（英文）" width="150" show-overflow-tooltip align="center" prop="itemNameEn" />
      <el-table-column label="物料编号" width="200" align="center" prop="itemCode" />
      <el-table-column label="物料子编号" width="200" align="center" prop="itemId" />
      <el-table-column label="销售订单号" width="150" show-overflow-tooltip align="center" prop="saleOrderCode" />
      <el-table-column label="规格型号" width="130" show-overflow-tooltip align="center" prop="spec" />
      <el-table-column label="批次号" width="130" align="center" prop="lot" />
      <el-table-column label="库位数量" align="center" prop="kcNum" />
      <el-table-column label="锁账数量" align="center" prop="lockNum" />
      <el-table-column label="可用数量" align="center" prop="kyNum" />
      <el-table-column label="实盘数量" align="center" prop="spNum" />
      <el-table-column label="总数量" align="center" prop="totalNum" />
      <el-table-column label="差异调整数量" width="130" align="center" prop="cyNum" />
      <el-table-column label="合同编号" width="150" align="center" prop="contractCode" />
      <el-table-column label="合同数量" align="center" prop="contractNum" />
      <el-table-column label="排产编号" width="150" align="center" prop="pcId" />
      <el-table-column label="供应商编码" width="130" show-overflow-tooltip align="center" prop="supplyId" />
      <el-table-column label="供应商名称" width="130" show-overflow-tooltip align="center" prop="supplyName" />
      <el-table-column label="配送在途" align="center" prop="psztNum" />
      <el-table-column label="流转在途" align="center" prop="lzztNum" />
      <el-table-column label="物料分类编码" width="130" show-overflow-tooltip align="center" prop="classId" />
      <el-table-column label="物料分类名称" width="130" show-overflow-tooltip align="center" prop="className" />
      <el-table-column label="物料单位" align="center" prop="unit" />
      <el-table-column label="仓库编码" width="130" align="center" prop="stockId" />
      <el-table-column label="仓库名称" width="150" show-overflow-tooltip align="center" prop="stockName" />
      <el-table-column label="库区编码" width="150" align="center" prop="kuquCode" />
      <el-table-column label="库区名称" width="150" show-overflow-tooltip align="center" prop="kuquName" />
      <el-table-column label="库位编码" width="130" show-overflow-tooltip align="center" prop="kuweiCode" />
      <el-table-column label="单价" align="center" prop="unitPrice" />
      <el-table-column label="金额" align="center" prop="totalPrice" />
      <el-table-column label="实时单价" align="center" prop="realPrice" />
      <el-table-column label="实时金额" align="center" prop="realTotalPrice" />
      <el-table-column label="差异金额" align="center" prop="cyTotalPrice" />
      <el-table-column label="实盘金额" align="center" prop="spTotalPrice" />
      <el-table-column label="订单满足率" align="center" prop="orderFill" />
      <el-table-column label="是否停用" align="center" prop="isStop" />
      <el-table-column label="是否呆滞" align="center" prop="isDaizhi" />
      <el-table-column label="是否拣货" align="center" prop="isJianhuo" />
      <el-table-column label="托管标志" align="center" prop="isTuoguan" />
      <el-table-column label="托盘码" align="center" prop="tuopanCode" />
      <el-table-column label="器具编号" width="130" align="center" prop="qijuCode" />
      <el-table-column label="条形码" width="150" show-overflow-tooltip align="center" prop="txm" />
      <el-table-column label="制造商编码" width="130" align="center" prop="makerCode" />
      <el-table-column label="制造商名称" width="130" show-overflow-tooltip align="center" prop="makerName" />
      <el-table-column label="质量状态" align="center" prop="qualityState" />
      <el-table-column label="尺寸" align="center" prop="size" />
      <el-table-column label="单重" align="center" prop="singleWeight" />
      <el-table-column label="总重" align="center" prop="totalWeight" />
      <el-table-column label="包装数量" align="center" prop="packingNum" />
      <el-table-column label="入库单号" width="130" align="center" prop="rukuId" />
      <el-table-column label="出库单号" width="130" align="center" prop="chukuId" />
      <el-table-column label="入库时间" align="center" prop="rukuDate" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.rukuDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="库存上限" align="center" prop="upLine" />
      <el-table-column label="库存下限" align="center" prop="downLine" />
      <el-table-column label="安全库存" align="center" prop="stockSafe" />
      <el-table-column label="使用状态" align="center" prop="useState" />
      <el-table-column label="颜色" align="center" prop="color" />
      <el-table-column label="花纹" align="center" prop="figure" />
      <el-table-column label="材质" align="center" prop="caizhi" />
      <el-table-column label="创建时间" width="160" align="center" prop="createTime" />
      <el-table-column label="创建者" align="center" prop="createBy" />
      <el-table-column label="更新时间" width="160" align="center" prop="updateTime" />
      <el-table-column label="更新者" align="center" prop="updateBy" />
      <el-table-column label="备注" width="150" show-overflow-tooltip align="center" prop="remark" />
      <el-table-column label="操作" fixed="right" width="120" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['business:ccStockInfo:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['business:ccStockInfo:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改库存明细对话框 -->
    <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="公司代码" prop="factoryCode">
          <el-input v-model="form.factoryCode" placeholder="请输入公司代码" />
        </el-form-item>
        <el-form-item label="公司名称" prop="factoryName">
          <el-input v-model="form.factoryName" placeholder="请输入公司名称" />
        </el-form-item>
        <el-form-item label="物料子图号" prop="itemCode">
          <el-input v-model="form.itemCode" placeholder="请输入物料子图号" />
        </el-form-item>
        <el-form-item label="物料名称" prop="itemName">
          <el-input v-model="form.itemName" placeholder="请输入物料名称" />
        </el-form-item>
        <el-form-item label="物料名称（英文）" prop="itemNameEn">
          <el-input v-model="form.itemNameEn" placeholder="请输入物料名称（英文）" />
        </el-form-item>
        <el-form-item label="物料图号" prop="itemId">
          <el-input v-model="form.itemId" placeholder="请输入物料图号" />
        </el-form-item>
        <el-form-item label="规格型号" prop="spec">
          <el-input v-model="form.spec" placeholder="请输入规格型号" />
        </el-form-item>
        <el-form-item label="批次号" prop="lot">
          <el-input v-model="form.lot" placeholder="请输入批次号" />
        </el-form-item>
        <el-form-item label="库位数量" prop="kcNum">
          <el-input v-model="form.kcNum" placeholder="请输入库位数量" />
        </el-form-item>
        <el-form-item label="锁账数量" prop="lockNum">
          <el-input v-model="form.lockNum" placeholder="请输入锁账数量" />
        </el-form-item>
        <el-form-item label="可用数量" prop="kyNum">
          <el-input v-model="form.kyNum" placeholder="请输入可用数量" />
        </el-form-item>
        <el-form-item label="实盘数量" prop="spNum">
          <el-input v-model="form.spNum" placeholder="请输入实盘数量" />
        </el-form-item>
        <el-form-item label="总数量" prop="totalNum">
          <el-input v-model="form.totalNum" placeholder="请输入总数量" />
        </el-form-item>
        <el-form-item label="差异调整数量" prop="cyNum">
          <el-input v-model="form.cyNum" placeholder="请输入差异调整数量" />
        </el-form-item>
        <el-form-item label="供应商" prop="supplyId">
          <el-input v-model="form.supplyId" placeholder="请输入供应商" />
        </el-form-item>
        <el-form-item label="配送在途" prop="psztNum">
          <el-input v-model="form.psztNum" placeholder="请输入配送在途" />
        </el-form-item>
        <el-form-item label="流转在途" prop="lzztNum">
          <el-input v-model="form.lzztNum" placeholder="请输入流转在途" />
        </el-form-item>
        <el-form-item label="供应商名称" prop="supplyName">
          <el-input v-model="form.supplyName" placeholder="请输入供应商名称" />
        </el-form-item>
        <el-form-item label="物料分类id" prop="classId">
          <el-input v-model="form.classId" placeholder="请输入物料分类id" />
        </el-form-item>
        <el-form-item label="物料分类" prop="className">
          <el-input v-model="form.className" placeholder="请输入物料分类" />
        </el-form-item>
        <el-form-item label="物料单位" prop="unit">
          <el-input v-model="form.unit" placeholder="请输入物料单位" />
        </el-form-item>
        <el-form-item label="部门id" prop="deptId">
          <el-input v-model="form.deptId" placeholder="请输入部门id" />
        </el-form-item>
        <el-form-item label="仓库编码" prop="stockId">
          <el-input v-model="form.stockId" placeholder="请输入仓库编码" />
        </el-form-item>
        <el-form-item label="仓库名称" prop="stockName">
          <el-input v-model="form.stockName" placeholder="请输入仓库名称" />
        </el-form-item>
        <el-form-item label="库区编码" prop="kuquCode">
          <el-input v-model="form.kuquCode" placeholder="请输入库区编码" />
        </el-form-item>
        <el-form-item label="库区名称" prop="kuquName">
          <el-input v-model="form.kuquName" placeholder="请输入库区名称" />
        </el-form-item>
        <el-form-item label="库位编码" prop="kuweiCode">
          <el-input v-model="form.kuweiCode" placeholder="请输入库位编码" />
        </el-form-item>
        <el-form-item label="单价" prop="unitPrice">
          <el-input v-model="form.unitPrice" placeholder="请输入单价" />
        </el-form-item>
        <el-form-item label="金额" prop="totalPrice">
          <el-input v-model="form.totalPrice" placeholder="请输入金额" />
        </el-form-item>
        <el-form-item label="实时单价" prop="realPrice">
          <el-input v-model="form.realPrice" placeholder="请输入实时单价" />
        </el-form-item>
        <el-form-item label="实时金额" prop="realTotalPrice">
          <el-input v-model="form.realTotalPrice" placeholder="请输入实时金额" />
        </el-form-item>
        <el-form-item label="差异金额" prop="cyTotalPrice">
          <el-input v-model="form.cyTotalPrice" placeholder="请输入差异金额" />
        </el-form-item>
        <el-form-item label="实盘金额" prop="spTotalPrice">
          <el-input v-model="form.spTotalPrice" placeholder="请输入实盘金额" />
        </el-form-item>
        <el-form-item label="排产编号" prop="pcId">
          <el-input v-model="form.pcId" placeholder="请输入排产编号" />
        </el-form-item>
        <el-form-item label="销售订单号" prop="saleOrderCode">
          <el-input v-model="form.saleOrderCode" placeholder="请输入销售订单号" />
        </el-form-item>
        <el-form-item label="合同编号" prop="contractCode">
          <el-input v-model="form.contractCode" placeholder="请输入合同编号" />
        </el-form-item>
        <el-form-item label="合同数量" prop="contractNum">
          <el-input v-model="form.contractNum" placeholder="请输入合同数量" />
        </el-form-item>
        <el-form-item label="订单满足率" prop="orderFill">
          <el-input v-model="form.orderFill" placeholder="请输入订单满足率" />
        </el-form-item>
        <el-form-item label="是否停用" prop="isStop">
          <el-input v-model="form.isStop" placeholder="请输入是否停用" />
        </el-form-item>
        <el-form-item label="是否呆滞" prop="isDaizhi">
          <el-input v-model="form.isDaizhi" placeholder="请输入是否呆滞" />
        </el-form-item>
        <el-form-item label="是否拣货" prop="isJianhuo">
          <el-input v-model="form.isJianhuo" placeholder="请输入是否拣货" />
        </el-form-item>
        <el-form-item label="托管标志" prop="isTuoguan">
          <el-input v-model="form.isTuoguan" placeholder="请输入托管标志" />
        </el-form-item>
        <el-form-item label="托盘码" prop="tuopanCode">
          <el-input v-model="form.tuopanCode" placeholder="请输入托盘码" />
        </el-form-item>
        <el-form-item label="器具编号" prop="qijuCode">
          <el-input v-model="form.qijuCode" placeholder="请输入器具编号" />
        </el-form-item>
        <el-form-item label="条形码" prop="txm">
          <el-input v-model="form.txm" placeholder="请输入条形码" />
        </el-form-item>
        <el-form-item label="制造商编码" prop="makerCode">
          <el-input v-model="form.makerCode" placeholder="请输入制造商编码" />
        </el-form-item>
        <el-form-item label="制造商名称" prop="makerName">
          <el-input v-model="form.makerName" placeholder="请输入制造商名称" />
        </el-form-item>
        <el-form-item label="质量状态" prop="qualityState">
          <el-input v-model="form.qualityState" placeholder="请输入质量状态" />
        </el-form-item>
        <el-form-item label="尺寸" prop="size">
          <el-input v-model="form.size" placeholder="请输入尺寸" />
        </el-form-item>
        <el-form-item label="单重" prop="singleWeight">
          <el-input v-model="form.singleWeight" placeholder="请输入单重" />
        </el-form-item>
        <el-form-item label="总重" prop="totalWeight">
          <el-input v-model="form.totalWeight" placeholder="请输入总重" />
        </el-form-item>
        <el-form-item label="包装数量" prop="packingNum">
          <el-input v-model="form.packingNum" placeholder="请输入包装数量" />
        </el-form-item>
        <el-form-item label="出库单号" prop="chukuId">
          <el-input v-model="form.chukuId" placeholder="请输入出库单号" />
        </el-form-item>
        <el-form-item label="入库单号" prop="rukuId">
          <el-input v-model="form.rukuId" placeholder="请输入入库单号" />
        </el-form-item>
        <el-form-item label="入库时间" prop="rukuDate">
          <el-date-picker clearable
            v-model="form.rukuDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择入库时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="库存上限" prop="upLine">
          <el-input v-model="form.upLine" placeholder="请输入库存上限" />
        </el-form-item>
        <el-form-item label="库存下限" prop="downLine">
          <el-input v-model="form.downLine" placeholder="请输入库存下限" />
        </el-form-item>
        <el-form-item label="安全库存" prop="stockSafe">
          <el-input v-model="form.stockSafe" placeholder="请输入安全库存" />
        </el-form-item>
        <el-form-item label="使用状态" prop="useState">
          <el-input v-model="form.useState" placeholder="请输入使用状态" />
        </el-form-item>
        <el-form-item label="颜色" prop="color">
          <el-input v-model="form.color" placeholder="请输入颜色" />
        </el-form-item>
        <el-form-item label="花纹" prop="figure">
          <el-input v-model="form.figure" placeholder="请输入花纹" />
        </el-form-item>
        <el-form-item label="材质" prop="caizhi">
          <el-input v-model="form.caizhi" placeholder="请输入材质" />
        </el-form-item>
        <el-form-item label="逻辑乐观锁" prop="version">
          <el-input v-model="form.version" placeholder="请输入逻辑乐观锁" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listCcStockInfo, getCcStockInfo, delCcStockInfo, addCcStockInfo, updateCcStockInfo } from "@/api/business/ccStockInfo";
import { getListClass} from "@/api/base/class";

export default {
  name: "CcStockInfo",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 库存明细表格数据
      ccStockInfoList: [],
      //物料分类
      classOptions: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        itemName: null,
        itemNameEn: null,
        itemId: null,
        itemCode: null,
        spec: null,
        lot: null,
        supplyId: null,
        supplyName: null,
        className: null,
        deptId: null,
        stockId: null,
        stockName: null,
        kuquCode: null,
        kuquName: null,
        kuweiCode: null,
        pcId: null,
        saleOrderCode: null,
        chukuId: null,
        rukuId: null,
        rukuDate: null,
        classId: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
    getListClass().then(response => {
      this.classOptions = response.data;
    });
  },
  methods: {
    /** 查询库存明细列表 */
    getList() {
      this.loading = true;
      listCcStockInfo(this.queryParams).then(response => {
        this.ccStockInfoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        factoryCode: null,
        factoryName: null,
        itemCode: null,
        itemName: null,
        itemNameEn: null,
        itemId: null,
        spec: null,
        lot: null,
        kcNum: null,
        lockNum: null,
        kyNum: null,
        spNum: null,
        totalNum: null,
        cyNum: null,
        supplyId: null,
        psztNum: null,
        lzztNum: null,
        supplyName: null,
        classId: null,
        className: null,
        unit: null,
        deptId: null,
        stockId: null,
        stockName: null,
        kuquCode: null,
        kuquName: null,
        kuweiCode: null,
        unitPrice: null,
        totalPrice: null,
        realPrice: null,
        realTotalPrice: null,
        cyTotalPrice: null,
        spTotalPrice: null,
        pcId: null,
        saleOrderCode: null,
        contractCode: null,
        contractNum: null,
        orderFill: null,
        isStop: null,
        isDaizhi: null,
        isJianhuo: null,
        isTuoguan: null,
        tuopanCode: null,
        qijuCode: null,
        txm: null,
        makerCode: null,
        makerName: null,
        qualityState: null,
        size: null,
        singleWeight: null,
        totalWeight: null,
        packingNum: null,
        chukuId: null,
        rukuId: null,
        rukuDate: null,
        upLine: null,
        downLine: null,
        stockSafe: null,
        useState: null,
        color: null,
        figure: null,
        caizhi: null,
        version: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加库存明细";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getCcStockInfo(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改库存明细";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateCcStockInfo(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addCcStockInfo(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除库存明细编号为"' + ids + '"的数据项？').then(function() {
        return delCcStockInfo(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('business/ccStockInfo/export', {
        ...this.queryParams
      }, `ccStockInfo_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
